package net.entelijan.cobean.bind.impl;

import static org.junit.Assert.assertEquals;

import java.util.ArrayList;
import java.util.List;

import net.entelijan.cobean.bind.impl.BoundPropBinding;

import org.junit.Test;

@SuppressWarnings("unused")
public class BoundPropertyBindingTestCase {
    
    @Test
    public void dummy() {
        // Created to let testcases succeed even if all tests are disabled
    }
    
    @Test  
    public void testStringProperty() {
        UnboundPropertyBean ub = new UnboundPropertyBean("ubInitial");
        BoundPropertyBean bb = new BoundPropertyBean("bbInitial", null);
        BoundPropBinding binding = new BoundPropBinding();
        binding.setModelPath("unbound");
        binding.setCompProperty("bound");
        ub = binding.bind(ub, bb);
        assertEquals("ubInitial", bb.getBound());
        ub.setUnbound("val001");
        assertEquals("val001", bb.getBound());
        ub.setUnbound("val002");
        assertEquals("val002", bb.getBound());
        bb.setBound("val003");
        assertEquals("val003", ub.getUnbound());
    }

    private List<RowBeanX> createRows() {
        ArrayList<RowBeanX> re = new ArrayList<RowBeanX>();
        re.add(new RowBeanX("", "", "", "", 1, 1, 1, 1));
        re.add(new RowBeanX("a", "", "", "", 2, 1, 1, 1));
        re.add(new RowBeanX("b", "A", "", "", 3, 1, 1, 1));
        re.add(new RowBeanX("c", "B", "a", "", 4, 1, 1, 1));
        re.add(new RowBeanX("d", "C", "b", "A", 5, 1, 1, 1));
        return re;
    }

}
